package com.humanresource.service.impl.clerkrecord;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.humanresource.constant.Constant;
import com.humanresource.dao.mapper.clerkrecord.ClerkrecordsMapper;
import com.humanresource.domain.po.clerkrecord.Clerkrecords;
import com.humanresource.domain.po.clerkrecord.ClerkrecordsExample;
import com.humanresource.service.clerkrecord.ClerkRecordService;

@Service
public class ClerkRecordServiceImpl implements ClerkRecordService {

	@Autowired
	private ClerkrecordsMapper clerkrecordsMapper;

	@Override
	public Clerkrecords findById(String recordId) {
		return clerkrecordsMapper.selectByPrimaryKey(recordId);
	}

	@Override
	public void insert(Clerkrecords records) {
		this.clerkrecordsMapper.insert(records);
	}

	@Override
	public List<Clerkrecords> findwithoutcheck() {
		ClerkrecordsExample clerkrecordsExample = new ClerkrecordsExample();
		ClerkrecordsExample.Criteria criteria = clerkrecordsExample
				.createCriteria();
		criteria.andAuditstateEqualTo("待复核");
		criteria.andIsdeleteNotEqualTo(Constant.DELETE);
		return this.clerkrecordsMapper.selectByExample(clerkrecordsExample);
	}

	@Override
	public void update(Clerkrecords clerkrecords) {
		this.clerkrecordsMapper.updateByPrimaryKeySelective(clerkrecords);
	}

	@Override
	public Clerkrecords findByClerkId(Integer clerkId) {
		ClerkrecordsExample clerkrecordsExample = new ClerkrecordsExample();
		ClerkrecordsExample.Criteria criteria = clerkrecordsExample
				.createCriteria();
		criteria.andClerkidEqualTo(clerkId);
		return this.clerkrecordsMapper.selectByExample(clerkrecordsExample)
				.get(0);
	}
}
